package com.zyz.action;

import com.opensymphony.xwork2.ActionSupport;
import com.zyz.model.User;
import com.zyz.service.IUserService;

public class LoginAction extends ActionSupport {
	private IUserService userService;
	private String userName;
	private String password;

	public LoginAction(IUserService userService, String userName,
			String password) {
		super();
		this.userService = userService;
		this.userName = userName;
		this.password = password;
	}

	public LoginAction() {
		super();
		// TODO Auto-generated constructor stub
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public IUserService getUserService() {
		return userService;
	}

	public void setUserService(IUserService userService) {
		this.userService = userService;
	}

	// @Override
	// public String execute() throws Exception {
	// System.out.println("execute()!!!!!!!!!");
	// System.out.println("userName:" + userName + " password:" + password);
	// if(this.userName.equals("admin") && this.password.equals("admin")){
	// return "123";
	// }
	//
	// return "321";
	// }

	@Override
	public String toString() {
		return "LoginAction [userName=" + userName + ", password=" + password
				+ "]";
	}

	public String userLogin() {
		try {
			User user = userService.checkUser(this.userName,this.password);
		} catch (Exception e) {
			// TODO: handle exception
			if(e.getMessage().equals("no user")){
				
			}else if(e.getMessage().equals("password error")){
				
			}
		}
		
		
		return "123";
	}

}
